"""存放配置信息"""
import logging
import redis


# 配置信息
class Config(object):
    # 配置秘钥
    SECRET_KEY = 'IPpbamOP9Ve5X8pDoCcd6zzv2oOHhuwvnsalEbfHLz4='

    DEBUG = False

    # 配置关联数据库
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@localhost/info'
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # 配置redis数据
    REDIS_HOST = 'localhost'
    REDIS_PORT = 6379

    # 配置Session扩展
    SESSION_TYPE = 'redis'
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    SESSION_USE_SIGNER = True
    PERMANENT_SESSION_LIFETIME = 65400 * 7

    # 配置sqlalchemy自动在teardown请求结束是自动提交到数据库
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True


# 开发环境的配置
class DevelopmentConfig(Config):
    DEBUG = True
    LOG_LEVEL = logging.DEBUG


# 开发环境的配置
class ProductionConfig(Config):
    DEBUG = False
    LOG_LEVEL = logging.ERROR
